<!-- 入库 -->
<template>
  <div class="warehousing">
    <van-nav-bar @click-right="onClickRight" safe-area-inset-top style="background: #3e96e8">
      <template #title>
        <span style="color: #fff">记录</span>
      </template>


    </van-nav-bar>

    <van-tabs v-model="active" color="#3e96e8" background="#F6F6F6" @click="onClick">
      <van-tab name="1" title="入库">
        <ruku ref="child1"></ruku>
      </van-tab>
      <van-tab name="2" title="出库">
        <chuku ref="child2"></chuku>
      </van-tab>
      <van-tab name="3" title="售卖">
        <third ref="child4"></third>
      </van-tab>
      <van-tab name="4" title="统计">
        <second ref="child3"></second>
      </van-tab>

    </van-tabs>
  </div>
</template>

<script>
import Bus from '../../utils/bus.js'
import ruku from "./module/ruku.vue";
import chuku from "./module/chuku.vue";
import second from "./module/second.vue";
import third from "./module/third.vue";
export default {
  name: "",
  components: {
    ruku,
    chuku,
    second,
    third,
  },
  data() {
    return {
      active: 0,
      addshow: true
    };
  },
  methods: {
    Bus() {
      var that = this;
      Bus.$on('warehouse', (data) => {

        console.log("warehouse", data);

        if (data == "2") {
          that.active = 1;

        } else if (data == "1") {
          that.active = 0;
        }




      })

    },
    onClick(name, title) {


      console.log("name", name);






    },
    onClickRight() { },

  },
  computed: {},
  watch: {},
  created() {



  },
  mounted() {

    var that = this;
    window.setWeight = function (data) {
      //that.getinfo(data);
      var weight = 0;
      data = data.replace(/\s+/g, "");
      if (data.indexOf(".") != -1) {
        var num1 = data.substring(0, data.indexOf("."));
        var num2 = data.substring(data.indexOf(".") + 1, 2);
        weight = parseInt(num1) + "." + num2;

      } else {
        weight = data;
      }
      //alert(weight);
      //  alert(that.active);

      if (that.active == "1") {
        that.$refs.child1.setData(weight)
      } else if (that.active == "2") {
        that.$refs.child2.setData(weight)
      } else if (that.active == "3") {
        that.$refs.child4.setData(weight)
      }



    };



  },
  beforeMount() {
    this.Bus()
  },
};
</script>

<style lang="scss" scoped>
.warehousing {
  width: 100%;
  height: 100%;
}
</style>